use std::io;
//标准输入
pub fn input() -> String {
    let mut str: String = String::new();
    io::stdin().read_line(&mut str).expect("get input faiied!");
    str
}

// 字符串转int32
#[allow(unused)]
pub fn to_i32(str: String) -> i32 {
    let num: i32 = str.trim().parse::<i32>().expect("转换i32失败");
    num
}

// 字符串转float32
#[allow(unused)]
pub fn to_f32(str: String) -> f32 {
    let num: f32 = str.trim().parse::<f32>().expect("转换f32失败");
    num
}

// 字符串转bool
#[allow(unused)]
pub fn to_bool(str: String) -> bool {
    let flag: bool = str.trim().parse::<bool>().expect("转换bool失败");
    flag
}

// 根据url获得文件名
#[allow(unused)]
pub fn get_file_name(str: String) -> String {
    let str_vec: Vec<&str> = str.split("/").collect();
    let file_name: &str = str_vec[str_vec.len() - 1];
    file_name.to_string()
}
